home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / MISCELLA / DVIWN281.ZIP / GENPK2.CMD < prev    next >
OS/2 REXX Batch file  |  1993-09-30  |  7KB  |  174 lines

  1. /*
  2.  * This is a sample REXX file to run metafont, convert the GF file to
  3.  * the PK format and store the PK font in the appropriate directory. It
  4.  * is meant to be called by dviwin and that's the reason for the absence
  5.  * of any parameter checking. It also assumes that metafont and gftopk
  6.  * are operating properly. This is a sample file and attempts to cover
  7.  * as many devices as possible; you will probably get better and faster
  8.  * results if you write a smaller and more specialized file.
  9.  *
  10.  * The plain base is a prerequisite: make sure that you generate it by
  11.  * running inimf on plain.mf, then input the file modes.mf and finally
  12.  * dump the format file. If you don't know what I am talking about,
  13.  * please read the documentation that comes with the Metafont program,
  14.  * as well as the Metafont book.
  15.  *
  16.  * You WILL need to modify the routine to place the PK files in the
  17.  * proper directory; the current method uses the environment variable
  18.  * DVIFONTS which is assumed to contain the base directory for the PK
  19.  * fonts. Any square-pixel fonts are assumed to be stored in the
  20.  * directories  $(DVIFONTS)\X  where X is the resolution of the font.
  21.  * Non-square-pixel fonts are assumed to stored in the directories
  22.  * $(DVIFONTS)\XxY where X is the horizontal resolution and Y is the
  23.  * vertical resolution.
  24.  *
  25.  * It is trivial to modify the name of metafont and the base directory;
  26.  * just select the proper values for the first two statements after
  27.  * these comments. If however you use another directory structure, you
  28.  * will also need to modify the definition of the variable pkdir_.
  29.  *
  30.  * You may also need to do more modifications if you have other devices;
  31.  * this file generates fonts for the screen, 300dpi laser and inkjet
  32.  * printers, printers, 600dpi laserjets, as well as 9-pin and 24-pin dot
  33.  * matrix printers. If you want to use another device, you will have to
  34.  * understand the code below and modify it accordingly (maybe you will
  35.  * want to rewrite the code in a compiled language to improve the speed,
  36.  * and the error handling). If you want to use a 9-pin dot matrix printer
  37.  * at 120x144dpi or 240x144dpi, add the following lines to the file modes.mf
  38.  * and regenerate the plain base.
  39.  *
  40.  * mode_def epsmed =            % Epson-FX at 240x144dpi
  41.  *     mode_param (pixels_per_inch, 240);
  42.  *     mode_param (aspect_ratio, 144 / pixels_per_inch);
  43.  *     EpsonMXFX_;
  44.  * enddef;
  45.  *
  46.  * mode_def epswlo =            % Epson-FX at 120x144dpi
  47.  *     mode_param (pixels_per_inch, 120);
  48.  *     mode_param (aspect_ratio, 144 / pixels_per_inch);
  49.  *     EpsonMXFX_;
  50.  * enddef;
  51.  *
  52.  * If Metafont does not recognize any other modes, it will generate
  53.  * its standard proofing fonts which are HUGE and inappropriate for
  54.  * your device. In that case, get the file modes.mf from CTAN and
  55.  * generate the plain base again using the command:
  56.  *         inimf plain;input modes;dump
  57.  * Then you need to copy plain.bas to the appropriate directory. You
  58.  * may need to replace "inimf" by "mf -i" for some versions of Metafont
  59.  *
  60.  * Here are the parameters passed by dviwin:
  61.  */
  62.     fname_    = WORD(ARG(1),1)
  63.     magst_    = WORD(ARG(1),2)
  64.     xres_    = WORD(ARG(1),3)
  65.     yres_    = WORD(ARG(1),4)
  66.     xbase_    = WORD(ARG(1),5)
  67.     ybase_    = WORD(ARG(1),6)
  68.     gfext_    = WORD(ARG(1),9)
  69. /*
  70.  * In most cases, you will only need to modify the next four lines:
  71.  */
  72.     mfcmd_    = 'mf'
  73.     pkbase_ = value('DVIFONTS',,'OS2ENVIRONMENT')
  74.     IF xbase_ = ybase_ THEN    pkdir_ = pkbase_'\'xres_
  75.     ELSE            pkdir_ = pkbase_'\'xres_'x'yres_
  76. /*
  77.  * Switch to the $TEMP or $TMP directory
  78.  */
  79.     temp_ = value('TEMP',,'OS2ENVIRONMENT')
  80.     if temp_ = '' THEN temp_ = value('TMP',,'OS2ENVIRONMENT')
  81.     CALL directory(temp_)
  82. /*
  83.  * If you want to switch to the directory of the current dvi file, uncomment
  84.  * the next statement. This is useful if you prefer to keep some mf sources
  85.  * in the dvi file directory instead of the $MFINPUTS directory.
  86.  *
  87.  * CALL directory(WORD(ARG(1),7)':'WORD(ARG(1),8))
  88.  */
  89. IF xbase_ = ybase_ THEN        /* Square pixels */
  90.     DO
  91.     pkdev_ = 'hplaser'
  92.     IF    xres_ =  58    THEN magst_ = -9
  93.     ELSE IF    xres_ =  64    THEN magst_ = -8.5
  94.     ELSE IF    xres_ =  70    THEN magst_ = -8
  95.     ELSE IF    xres_ =  76    THEN magst_ = -7.5
  96.     ELSE IF    xres_ =  84    THEN magst_ = -7
  97.     ELSE IF    xres_ =  92    THEN magst_ = -6.5
  98.     ELSE IF    xres_ = 100    THEN magst_ = -6
  99.     ELSE IF    xres_ = 110    THEN magst_ = -5.5
  100.     ELSE IF    xres_ = 121    THEN magst_ = -5
  101.     ELSE IF    xres_ = 132    THEN magst_ = -4.5
  102.     ELSE IF    xres_ = 145    THEN magst_ = -4
  103.     ELSE IF    xres_ = 158    THEN magst_ = -3.5
  104.     ELSE IF    xres_ = 174    THEN magst_ = -3
  105.     ELSE IF    xres_ = 190    THEN magst_ = -2.5
  106.     ELSE IF    xres_ = 208    THEN magst_ = -2
  107.     ELSE IF    xres_ = 228    THEN magst_ = -1.5
  108.     ELSE IF    xres_ = 250    THEN magst_ = -1
  109.     ELSE IF    xres_ = 274    THEN magst_ = -0.5
  110.     ELSE IF    xres_ = 300    THEN magst_ =  0
  111.     ELSE IF    xres_ = 329    THEN magst_ =  0.5
  112.     ELSE IF    xres_ = 360    THEN magst_ =  1
  113.     ELSE IF    xres_ = 394    THEN magst_ =  1.5
  114.     ELSE IF    xres_ = 432    THEN magst_ =  2
  115.     ELSE IF    xres_ = 473    THEN magst_ =  2.5
  116.     ELSE IF    xres_ = 518    THEN magst_ =  3
  117.     ELSE IF    xres_ = 568    THEN magst_ =  3.5
  118.     ELSE IF    xres_ = 622    THEN magst_ =  4
  119.     ELSE IF    xres_ = 681    THEN magst_ =  4.5
  120.     ELSE IF    xres_ = 746    THEN magst_ =  5
  121.     ELSE IF    xres_ = 818    THEN magst_ =  5.5
  122.     ELSE IF    xres_ = 896    THEN magst_ =  6
  123.     ELSE IF    xres_ = 981    THEN magst_ =  6.5
  124.     ELSE IF    xres_ = 1075    THEN magst_ =  7
  125.     ELSE IF    xres_ = 1178    THEN magst_ =  7.5
  126.     ELSE IF    xres_ = 1290    THEN magst_ =  8
  127.     ELSE
  128.         DO
  129.         IF    ybase_ = 180    THEN pkdev_ = 'lqlores'
  130.         ELSE IF    ybase_ = 360    THEN pkdev_ = 'lqhires'
  131.         ELSE IF    ybase_ = 300    THEN pkdev_ = 'hplaser'
  132.         ELSE IF    ybase_ = 400    THEN pkdev_ = 'nexthi'
  133.         ELSE IF    ybase_ = 600    THEN pkdev_ = 'ljiv'
  134.         ELSE SIGNAL UNKNOWN
  135.         END
  136.     END
  137. ELSE                /* Non-square pixels */
  138.     DO
  139.     IF    xbase_ = 120 & ybase_ =  72    THEN pkdev_ = 'epsdraft'
  140.     ELSE IF    xbase_ = 240 & ybase_ = 216    THEN pkdev_ = 'epsonfx'
  141.     ELSE IF    xbase_ = 360 & ybase_ = 180    THEN pkdev_ = 'lqmedres'
  142.     ELSE IF    xbase_ = 120 & ybase_ = 144    THEN pkdev_ = 'epswlo'
  143.     ELSE IF    xbase_ = 240 & ybase_ = 144    THEN pkdev_ = 'epsmed'
  144.     ELSE SIGNAL UNKNOWN
  145.     END
  146. CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  147. CALL SysLoadFuncs
  148. IF stream(pkdir_'\'fname_'.pk','c','query exists') <> '' THEN EXIT
  149. mfcmd_' \scrollmode;mode:='pkdev_';mag:=magstep('magst_');input 'fname_
  150. IF RC > 0 THEN SIGNAL ERROR_EXIT
  151. CALL SysMkDir(pkbase_)
  152. CALL SysMkDir(pkdir_)
  153. IF stream(fname_'.'gfext_,'c','query exists') = '' THEN gfext_ = xres_
  154. gftopk fname_'.'gfext_ pkdir_'\'fname_'.pk'
  155. CALL SysFileDelete(fname_'.'gfext_)
  156. CALL SysFileDelete(fname_'.log')
  157. /*
  158.  * If you want to copy the TFM file to the appropriate directory, here
  159.  * is the place to do it.
  160.  */
  161. CALL SysFileDelete(fname_'.tfm')
  162. EXIT
  163.  
  164. /*
  165.  * This is where we come if we don't know about the requested resolution
  166.  */
  167. UNKNOWN:    SAY "I don't know the Metafont mode for this device. Please"
  168.         SAY "add this information to the file genpk.cmd"
  169. ERROR_EXIT:    SAY "Press Enter to continue..."
  170.                 '@echo off'
  171.         'echo ERROR > 'temp_'\error$_$'
  172.         PULL junk_
  173.         EXIT
  174.